<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    main
    <iframe src="./02iframe1.html" width="400px" height="400px"></iframe>
    <script>
        var myName = 'main'
        var iframe = document.getElementsByTagName('iframe')[0];
        iframe.onload = function() {
            console.log(iframe);
            // 通过contentWindow获取iframe的window对象
            console.log(iframe.contentWindow);
            console.log(iframe.contentWindow.myName);
        }
        iframe.contentWindow.location = 'https://www.baidu.com'
    </script>
</body>

</html>